package com.zucc.eye.dto;

import com.alibaba.fastjson.JSONObject;
import com.zucc.eye.entity.License;
import com.zucc.eye.entity.Owner;
import com.zucc.eye.entity.Repo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @description repo
 * @author zhengkai.blog.csdn.net
 * @date 2022-02-12
 */
//@Entity
@Builder
@AllArgsConstructor
@Data
//@Table(name="repo")
@ApiModel("repo")
@Slf4j
@ToString
public class RepoDto implements Serializable {

  public    Repo toEntity(){
        Repo repo = new Repo();
        BeanUtils.copyProperties(this,repo);
        //一个实体没办法复制吧
      String stringOwner = JSONObject.toJSONString(owner);
      //owner
      repo.setOwner(stringOwner);
      //JSONObject.parseObject(repo,Repo.class);
      //license
      //String stringOwner = JSONObject.toJSONString(owner);
      //owner
      repo.setLicense( JSONObject.toJSONString(license));
      repo.setTopics( JSONObject.toJSONString(topics));
        return repo;
    }

    public static void main(String[] args) {
        Owner build = Owner.builder().avatar_url("313131").build();
        License license = License.builder().key("313131").build();
        List<String> list = Arrays.asList("1", "2");
        RepoDto build1 = RepoDto.builder().owner(build).
                license(license).
                topics(list).
                build();
        Repo repo = build1.toEntity();
        //没有复制成功
        log.info(" build {}",build);
        log.info(" build1 {}",build1);
        log.info(" repo {}",repo);


    }

    private static final long serialVersionUID = 1L;

    //@Id
    //@ApiModelProperty("id")
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /**
    * node_id
    */
    @ApiModelProperty("node_id")
    @Column(name="node_id")
    private String nodeId;

    /**
    * name
    */
    @ApiModelProperty("name")
    @Column(name="name")
    private String name;

    /**
    * full_name
    */
    @ApiModelProperty("full_name")
    @Column(name="full_name")
    private String fullName;

    /**
    * isprivate
    */
    @ApiModelProperty("isprivate")
    @Column(name="isprivate")
    private Integer isprivate;

    /**
    * owner
    */
    @ApiModelProperty("owner")
    @Column(name="owner")
    private Owner owner;

    /**
    * html_url
    */
    @ApiModelProperty("html_url")
    @Column(name="html_url")
    private String htmlUrl;

    /**
    * description
    */
    @ApiModelProperty("description")
    @Column(name="description")
    private String description;

    /**
    * fork
    */
    @ApiModelProperty("fork")
    @Column(name="fork")
    private Integer fork;

    /**
    * url
    */
    @ApiModelProperty("url")
    @Column(name="url")
    private String url;

    /**
    * forks_url
    */
    @ApiModelProperty("forks_url")
    @Column(name="forks_url")
    private String forksUrl;

    /**
    * keys_url
    */
    @ApiModelProperty("keys_url")
    @Column(name="keys_url")
    private String keysUrl;

    /**
    * collaborators_url
    */
    @ApiModelProperty("collaborators_url")
    @Column(name="collaborators_url")
    private String collaboratorsUrl;

    /**
    * teams_url
    */
    @ApiModelProperty("teams_url")
    @Column(name="teams_url")
    private String teamsUrl;

    /**
    * hooks_url
    */
    @ApiModelProperty("hooks_url")
    @Column(name="hooks_url")
    private String hooksUrl;

    /**
    * issue_events_url
    */
    @ApiModelProperty("issue_events_url")
    @Column(name="issue_events_url")
    private String issueEventsUrl;

    /**
    * events_url
    */
    @ApiModelProperty("events_url")
    @Column(name="events_url")
    private String eventsUrl;

    /**
    * assignees_url
    */
    @ApiModelProperty("assignees_url")
    @Column(name="assignees_url")
    private String assigneesUrl;

    /**
    * branches_url
    */
    @ApiModelProperty("branches_url")
    @Column(name="branches_url")
    private String branchesUrl;

    /**
    * tags_url
    */
    @ApiModelProperty("tags_url")
    @Column(name="tags_url")
    private String tagsUrl;

    /**
    * blobs_url
    */
    @ApiModelProperty("blobs_url")
    @Column(name="blobs_url")
    private String blobsUrl;

    /**
    * git_tags_url
    */
    @ApiModelProperty("git_tags_url")
    @Column(name="git_tags_url")
    private String gitTagsUrl;

    /**
    * git_refs_url
    */
    @ApiModelProperty("git_refs_url")
    @Column(name="git_refs_url")
    private String gitRefsUrl;

    /**
    * trees_url
    */
    @ApiModelProperty("trees_url")
    @Column(name="trees_url")
    private String treesUrl;

    /**
    * statuses_url
    */
    @ApiModelProperty("statuses_url")
    @Column(name="statuses_url")
    private String statusesUrl;

    /**
    * languages_url
    */
    @ApiModelProperty("languages_url")
    @Column(name="languages_url")
    private String languagesUrl;

    /**
    * stargazers_url
    */
    @ApiModelProperty("stargazers_url")
    @Column(name="stargazers_url")
    private String stargazersUrl;

    /**
    * contributors_url
    */
    @ApiModelProperty("contributors_url")
    @Column(name="contributors_url")
    private String contributorsUrl;

    /**
    * subscribers_url
    */
    @ApiModelProperty("subscribers_url")
    @Column(name="subscribers_url")
    private String subscribersUrl;

    /**
    * subscription_url
    */
    @ApiModelProperty("subscription_url")
    @Column(name="subscription_url")
    private String subscriptionUrl;

    /**
    * commits_url
    */
    @ApiModelProperty("commits_url")
    @Column(name="commits_url")
    private String commitsUrl;

    /**
    * git_commits_url
    */
    @ApiModelProperty("git_commits_url")
    @Column(name="git_commits_url")
    private String gitCommitsUrl;

    /**
    * comments_url
    */
    @ApiModelProperty("comments_url")
    @Column(name="comments_url")
    private String commentsUrl;

    /**
    * issue_comment_url
    */
    @ApiModelProperty("issue_comment_url")
    @Column(name="issue_comment_url")
    private String issueCommentUrl;

    /**
    * contents_url
    */
    @ApiModelProperty("contents_url")
    @Column(name="contents_url")
    private String contentsUrl;

    /**
    * compare_url
    */
    @ApiModelProperty("compare_url")
    @Column(name="compare_url")
    private String compareUrl;

    /**
    * merges_url
    */
    @ApiModelProperty("merges_url")
    @Column(name="merges_url")
    private String mergesUrl;

    /**
    * archive_url
    */
    @ApiModelProperty("archive_url")
    @Column(name="archive_url")
    private String archiveUrl;

    /**
    * downloads_url
    */
    @ApiModelProperty("downloads_url")
    @Column(name="downloads_url")
    private String downloadsUrl;

    /**
    * issues_url
    */
    @ApiModelProperty("issues_url")
    @Column(name="issues_url")
    private String issuesUrl;

    /**
    * pulls_url
    */
    @ApiModelProperty("pulls_url")
    @Column(name="pulls_url")
    private String pullsUrl;

    /**
    * milestones_url
    */
    @ApiModelProperty("milestones_url")
    @Column(name="milestones_url")
    private String milestonesUrl;

    /**
    * notifications_url
    */
    @ApiModelProperty("notifications_url")
    @Column(name="notifications_url")
    private String notificationsUrl;

    /**
    * labels_url
    */
    @ApiModelProperty("labels_url")
    @Column(name="labels_url")
    private String labelsUrl;

    /**
    * releases_url
    */
    @ApiModelProperty("releases_url")
    @Column(name="releases_url")
    private String releasesUrl;

    /**
    * deployments_url
    */
    @ApiModelProperty("deployments_url")
    @Column(name="deployments_url")
    private String deploymentsUrl;

    /**
    * created_at
    */
    @ApiModelProperty("created_at")
    @Column(name="created_at")
    private String createdAt;

    /**
    * updated_at
    */
    @ApiModelProperty("updated_at")
    @Column(name="updated_at")
    private String updatedAt;

    /**
    * pushed_at
    */
    @ApiModelProperty("pushed_at")
    @Column(name="pushed_at")
    private String pushedAt;

    /**
    * git_url
    */
    @ApiModelProperty("git_url")
    @Column(name="git_url")
    private String gitUrl;

    /**
    * ssh_url
    */
    @ApiModelProperty("ssh_url")
    @Column(name="ssh_url")
    private String sshUrl;

    /**
    * clone_url
    */
    @ApiModelProperty("clone_url")
    @Column(name="clone_url")
    private String cloneUrl;

    /**
    * svn_url
    */
    @ApiModelProperty("svn_url")
    @Column(name="svn_url")
    private String svnUrl;

    /**
    * homepage
    */
    @ApiModelProperty("homepage")
    @Column(name="homepage")
    private String homepage;

    /**
    * size
    */
    @ApiModelProperty("size")
    @Column(name="size")
    private Integer size;

    /**
    * stargazers_count
    */
    @ApiModelProperty("stargazers_count")
    @Column(name="stargazers_count")
    private Integer stargazersCount;

    /**
    * watchers_count
    */
    @ApiModelProperty("watchers_count")
    @Column(name="watchers_count")
    private Integer watchersCount;

    /**
    * language
    */
    @ApiModelProperty("language")
    @Column(name="language")
    private String language;

    /**
    * has_issues
    */
    @ApiModelProperty("has_issues")
    @Column(name="has_issues")
    private Integer hasIssues;

    /**
    * has_projects
    */
    @ApiModelProperty("has_projects")
    @Column(name="has_projects")
    private Integer hasProjects;

    /**
    * has_downloads
    */
    @ApiModelProperty("has_downloads")
    @Column(name="has_downloads")
    private Integer hasDownloads;

    /**
    * has_wiki
    */
    @ApiModelProperty("has_wiki")
    @Column(name="has_wiki")
    private Integer hasWiki;

    /**
    * has_pages
    */
    @ApiModelProperty("has_pages")
    @Column(name="has_pages")
    private Integer hasPages;

    /**
    * forks_count
    */
    @ApiModelProperty("forks_count")
    @Column(name="forks_count")
    private Integer forksCount;

    /**
    * mirror_url
    */
    @ApiModelProperty("mirror_url")
    @Column(name="mirror_url")
    private String mirrorUrl;

    /**
    * archived
    */
    @ApiModelProperty("archived")
    @Column(name="archived")
    private Integer archived;

    /**
    * disabled
    */
    @ApiModelProperty("disabled")
    @Column(name="disabled")
    private Integer disabled;

    /**
    * open_issues_count
    */
    @ApiModelProperty("open_issues_count")
    @Column(name="open_issues_count")
    private Integer openIssuesCount;

    /**
    * license
    */
    @ApiModelProperty("license")
    @Column(name="license")
    private License license;

    /**
    * allow_forking
    */
    @ApiModelProperty("allow_forking")
    @Column(name="allow_forking")
    private Integer allowForking;

    /**
    * is_template
    */
    @ApiModelProperty("is_template")
    @Column(name="is_template")
    private Integer isTemplate;

    /**
    * topics
    */
    //@ApiModelProperty("topics")
    //@Column(name="topics")
    private List<String > topics;

    /**
    * visibility
    */
    @ApiModelProperty("visibility")
    @Column(name="visibility")
    private String visibility;

    /**
    * forks
    */
    @ApiModelProperty("forks")
    @Column(name="forks")
    private Integer forks;

    /**
    * open_issues
    */
    @ApiModelProperty("open_issues")
    @Column(name="open_issues")
    private Integer openIssues;

    /**
    * watchers
    */
    @ApiModelProperty("watchers")
    @Column(name="watchers")
    private Integer watchers;

    /**
    * default_branch
    */
    @ApiModelProperty("default_branch")
    @Column(name="default_branch")
    private String defaultBranch;

    /**
    * temp_clone_token
    */
    @ApiModelProperty("temp_clone_token")
    @Column(name="temp_clone_token")
    private String tempCloneToken;

    /**
    * network_count
    */
    @ApiModelProperty("network_count")
    @Column(name="network_count")
    private Integer networkCount;

    /**
    * subscribers_count
    */
    @ApiModelProperty("subscribers_count")
    @Column(name="subscribers_count")
    private Integer subscribersCount;

    public RepoDto() {
    }

}